﻿/*
版权所有：版权所有(C) 2010，刘建新
文件编号：M01_BaseChatTools.cs
文件名称：BaseChatTools.cs
系统编号：Z0003007
系统名称：通用办公系统
模块编号：M01
模块名称：信息发布
设计文档：IOA_M01信息发布XDE建模.mdx
完成日期：2010/12/17
作　　者：
内容摘要：表[Base_Chat_Tools]对应的实体类
*/

using System;
using System.Collections;
using System.Data;


namespace Eis51.CampanyCMS.Model.OnlineService
{
		/// <summary>
		/// 类 编 号：
		/// 类 名 称：BaseChatTools
		/// 内容摘要：
		/// </summary>
		
		[Serializable]
		public class BaseChatTools : BaseModel
		{
		#region 自动生成代码
		
			#region 重载Equals/GetHashCode
			/// <summary>
			/// 重载Equals			
			/// </summary>
			public override bool Equals (Object obj)
			{
				if (obj != null && obj is BaseChatTools)
				{
					if (obj == this)
						return true;
					BaseChatTools castObj = (BaseChatTools)obj; 
					
					if (!this.m_Seqno.Equals(castObj.Seqno))
						return false;
						
					if (!this.m_ChatToolCode.Equals(castObj.ChatToolCode))
						return false;
						
					if (!this.m_ChatToolName.Equals(castObj.ChatToolName))
						return false;
						
					if (!this.m_ChatToolTemplate.Equals(castObj.ChatToolTemplate))
						return false;
						
					return true;
				}
				return false;
			}
			
			/// <summary>
			/// 重载GetHashCode
			/// </summary>
			public override int GetHashCode()
			{
					int hash = 0;					
					
					hash = hash <<  8;
					if ((object)m_Seqno != null)
					{
						hash = hash ^ m_Seqno.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_ChatToolCode != null)
					{
						hash = hash ^ m_ChatToolCode.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_ChatToolName != null)
					{
						hash = hash ^ m_ChatToolName.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_ChatToolTemplate != null)
					{
						hash = hash ^ m_ChatToolTemplate.GetHashCode();
					}
						
					return hash; 
			}
			#endregion
			
			public BaseChatTools()
			{
				MarkNew();
			}						
			
			public BaseChatTools GetOldValue()
			{
				return OldValue as BaseChatTools;
			}
		
		#region Seqno属性
			private int m_Seqno = 0;
			/// <summary>
			/// 属性名称： Seqno
			/// 内容摘要： DB列名：Seqno[主键]
			///            DB类型：int
			/// </summary>
			public int Seqno
			{
				get
					{
						return m_Seqno;
					}
				set
					{
						if (m_Seqno as object == null || !m_Seqno.Equals(value))
						{
							m_Seqno = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region ChatToolCode属性
			private string m_ChatToolCode = String.Empty;
			/// <summary>
			/// 属性名称： ChatToolCode
			/// 内容摘要： DB列名：Chat_Tool_CODE[工具CODE]
			///            DB类型：string
			/// </summary>
			public string ChatToolCode
			{
				get
					{
						return m_ChatToolCode;
					}
				set
					{
						if (m_ChatToolCode as object == null || !m_ChatToolCode.Equals(value))
						{
							m_ChatToolCode = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region ChatToolName属性
			private string m_ChatToolName = String.Empty;
			/// <summary>
			/// 属性名称： ChatToolName
			/// 内容摘要： DB列名：Chat_Tool_Name[工具名称]
			///            DB类型：string
			/// </summary>
			public string ChatToolName
			{
				get
					{
						return m_ChatToolName;
					}
				set
					{
						if (m_ChatToolName as object == null || !m_ChatToolName.Equals(value))
						{
							m_ChatToolName = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region ChatToolTemplate属性
			private string m_ChatToolTemplate = String.Empty;
			/// <summary>
			/// 属性名称： ChatToolTemplate
			/// 内容摘要： DB列名：Chat_Tool_Template[｛CHAT_NUM｝:替换为‘聊天帐号’，{CHAT_STYLE}:替换为聊天风格]
			///            DB类型：string
			/// </summary>
			public string ChatToolTemplate
			{
				get
					{
						return m_ChatToolTemplate;
					}
				set
					{
						if (m_ChatToolTemplate as object == null || !m_ChatToolTemplate.Equals(value))
						{
							m_ChatToolTemplate = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region static CreateDataTable/FillDataRow/DataRow2Obj/Dt2Objs/FillDataTable
			/// <summary>
			/// 得到实体对应的DataTable
			/// </summary>
			/// <param name="tableName">表名</param>
			/// <param name="cne">列名映射选择:DB列名或属性名</param>
			/// <returns>生成的DataTable</returns>
			static public DataTable CreateDataTable(string tableName,ColumnNameEnum cne)
			{
				DataTable dtResult = new DataTable(tableName);
			
				if (cne == ColumnNameEnum.DBName)
				{
					dtResult.Columns.Add(new DataColumn("Seqno",typeof(int)));
					dtResult.Columns.Add(new DataColumn("Chat_Tool_CODE",typeof(string)));
					dtResult.Columns.Add(new DataColumn("Chat_Tool_Name",typeof(string)));
					dtResult.Columns.Add(new DataColumn("Chat_Tool_Template",typeof(string)));
				}
				else if (cne == ColumnNameEnum.PropertyName)
				{
					dtResult.Columns.Add(new DataColumn("Seqno",typeof(int)));
					dtResult.Columns.Add(new DataColumn("ChatToolCode",typeof(string)));
					dtResult.Columns.Add(new DataColumn("ChatToolName",typeof(string)));
					dtResult.Columns.Add(new DataColumn("ChatToolTemplate",typeof(string)));
				}
				return dtResult;
			}
			
			/// <summary>
			/// 得到实体对应的DataTable
			/// </summary>
			/// <param name="cne">列名映射选择:DB列名或属性名</param>
			/// <returns>生成的DataTable</returns>
			static public DataTable CreateDataTable(ColumnNameEnum cne)
			{
				return CreateDataTable(null,cne);
			}

			/// <summary>
			/// 得到实体对应的DataTable(默认列名映射为属性名)
			/// </summary>
			/// <returns>生成的DataTable</returns>
			static public DataTable CreateDataTable()
			{
				return CreateDataTable(ColumnNameEnum.PropertyName);
			}
			
			/// <summary>
			/// 用当前对象值填充DaraRow
			/// </summary>
			/// <param name="dr">由CreateTable生成的DataTable通过NewRow得到的DataRow对象</param>
			/// <param name="cne">dr的列名映射方式:DB列名或属性名</param>
			public void FillDataRow(DataRow dr,ColumnNameEnum cne)
			{
				if (dr == null)
				{
					throw new ArgumentNullException("dr");
				}
				if (ColumnNameEnum.DBName == cne)
				{
					dr["Seqno"] = this.Seqno;
					dr["Chat_Tool_CODE"] = this.ChatToolCode;
					dr["Chat_Tool_Name"] = this.ChatToolName;
					dr["Chat_Tool_Template"] = this.ChatToolTemplate;
				}
				else if (ColumnNameEnum.PropertyName == cne)
				{
					dr["Seqno"] = this.Seqno;
					dr["ChatToolCode"] = this.ChatToolCode;
					dr["ChatToolName"] = this.ChatToolName;
					dr["ChatToolTemplate"] = this.ChatToolTemplate;					
				}
			}
			
			/// <summary>
			/// 用当前对象值填充DaraRow(默认列名映射为属性名)
			/// </summary>
			/// <param name="dr">由CreateTable生成的DataTable通过NewRow得到的DataRow对象</param>
			public void FillDataRow(DataRow dr)
			{
				this.FillDataRow(dr,ColumnNameEnum.PropertyName);
			}
			
			/// <summary>
			/// 将DataRow转换成BaseChatTools对象
			/// </summary>
			/// <param name="dr">由CreateTable生成的DataTable通过NewRow得到的DataRow对象</param>
			/// <param name="cne">dr的列名映射方式:DB列名或属性名</param>
			/// <returns>BaseChatTools对象</returns>
			public static BaseChatTools Dr2Obj(DataRow dr,ColumnNameEnum cne)
			{
				if (dr == null)
				{
					throw new ArgumentNullException("dr");
				}
				BaseChatTools obj = new BaseChatTools();
				if (ColumnNameEnum.DBName == cne)
				{
					obj.Seqno = (dr["Seqno"] == Convert.DBNull) ? 0  : (int)Convert.ChangeType(dr["Seqno"],typeof(int));
					obj.ChatToolCode = (dr["Chat_Tool_CODE"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["Chat_Tool_CODE"],typeof(string));
					obj.ChatToolName = (dr["Chat_Tool_Name"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["Chat_Tool_Name"],typeof(string));
					obj.ChatToolTemplate = (dr["Chat_Tool_Template"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["Chat_Tool_Template"],typeof(string));
				}
				else if (ColumnNameEnum.PropertyName == cne)
				{
					obj.Seqno = (dr["Seqno"] == Convert.DBNull) ? 0  : (int)Convert.ChangeType(dr["Seqno"],typeof(int));
					obj.ChatToolCode = (dr["ChatToolCode"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["ChatToolCode"],typeof(string));
					obj.ChatToolName = (dr["ChatToolName"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["ChatToolName"],typeof(string));
					obj.ChatToolTemplate = (dr["ChatToolTemplate"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["ChatToolTemplate"],typeof(string));		
				}
				
				return obj;
			}
			
			/// <summary>
			/// 将DataRow转换成BaseChatTools对象(默认列名映射为属性名)
			/// </summary>
			/// <returns>BaseChatTools对象</returns>
			public static BaseChatTools Dr2Obj(DataRow dr)
			{
				return Dr2Obj(dr,ColumnNameEnum.DBName);
			}
			
			/// <summary>
			/// 将DataTabe转换成的BaseChatTools对象集合
			/// </summary>
			/// <param name="dt">由CreateTable生成的DataTable</param>
			/// <param name="cne">dt的列名映射方式:DB列名或属性名</param>
			/// <returns>BaseChatTools对象的集合</returns>
			public static IList Dt2Objs(DataTable dt,ColumnNameEnum cne)
			{
				if (dt == null)
				{
					throw new ArgumentNullException("dt");
				}
				
				ArrayList alResult = new ArrayList();
				
				foreach(DataRow dr in dt.Rows)
				{
					alResult.Add(Dr2Obj(dr,cne));
				}
				
				return alResult;
			}

			/// <summary>
			/// 将DataTabe转换成的BaseChatTools对象集合(默认列名映射为属性名)
			/// </summary>
			/// <param name="dt">由CreateTable生成的DataTable</param>
			/// <returns>BaseChatTools对象的集合</returns>
			public static IList Dt2Objs(DataTable dt)
			{
				return Dt2Objs(dt,ColumnNameEnum.PropertyName);
			}
			
			/// <summary>
			/// 用objs的BaseChatTools对象集合填充DataTable
			/// </summary>
			/// <param name="dt">由CreateTable生成的DataTable</param>
			/// <param name="objs">BaseChatTools对象集合</param>
			/// <param name="cne">dt的列名映射方式:DB列名或属性名</param>
			public static void FillDataTable(DataTable dt,IList objs,ColumnNameEnum cne)
			{
				if (dt == null)
				{
					throw new ArgumentNullException("dt");
				}
				if (objs == null)
				{
					throw new ArgumentNullException("objs");
				}
				
				foreach(BaseChatTools obj in objs)
				{
					DataRow dr = dt.NewRow();
					obj.FillDataRow(dr,cne);
					dt.Rows.Add(dr);
				}
			}

			/// <summary>
			/// 用objs的BaseChatTools对象集合填充DataTable(默认列名映射为属性名)
			/// </summary>
			/// <param name="dt">由CreateTable生成的DataTable</param>
			/// <param name="objs">BaseChatTools对象集合</param>
			public static void FillDataTable(DataTable dt,IList objs)
			{
				FillDataTable(dt,objs,ColumnNameEnum.PropertyName);
			}
		#endregion
		
		/// <summary>
		/// 取消编辑,恢复到上次有效调用BeginEdit前的状态,并清空保留值
		/// </summary>
		public override void CancelEdit()
		{
			BaseChatTools old = this.OldValue as BaseChatTools;
			if (old != null)
			{
					this.Seqno = old.Seqno;
					this.ChatToolCode = old.ChatToolCode;
					this.ChatToolName = old.ChatToolName;
					this.ChatToolTemplate = old.ChatToolTemplate;				
				this.OldValue = null;
			}
		}
		
		
		
		
		#region BaseChatTools实体的内部Key类
			/// <summary>
			/// BaseChatTools实体的Key类
			/// </summary>
			public sealed class Key
			{
		
				private int m_Seqno;
				public int Seqno
				{
 					get 
					{ 
						 return m_Seqno; 
					}
					set 
					{ 
						m_Seqno = value;
					}
				}
		
				public Key(int pSeqno)
				{
					m_Seqno=pSeqno;

				}
			}
		#endregion
			/// <summary>
			/// 得到实体BaseChatTools的PK
			/// </summary>
			public Key GetKey()
			{
				return new Key(Seqno);				
			}
			
				
		#endregion
	}
}
